package com.shfl;

import com.shfl.stock.Stock;
import com.shfl.utils.PropertiesUtil;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {
        Stock.width = Integer.valueOf(PropertiesUtil.getProperty(Stock.proUrl, "project.width"));
        Stock.height = Integer.valueOf(PropertiesUtil.getProperty(Stock.proUrl, "project.height"));
        Stock.INDEX_STAGE = primaryStage;
        // Parent root = FXMLLoader.load(getClass().getResource("/fxml/index.fxml"));
        Stock.INDEX_STAGE.setTitle(PropertiesUtil.getProperty(Stock.proUrl, "project.name"));
        Stock.INDEX_STAGE.getIcons().add(new Image(getClass().getResourceAsStream(PropertiesUtil.getProperty(Stock.proUrl, "project.icons"))));
        Stock.INDEX_STAGE.setScene(new Scene(Stock.parent1(), Stock.width, Stock.height));
        Stock.INDEX_STAGE.show();


        //关闭事件
        Stock.INDEX_STAGE.setOnCloseRequest((event -> {
                    Stock.executor.shutdownNow();
                })
        );

    }

    public void showWindow() throws Exception {
        start(Stock.INDEX_STAGE);
    }

    @Override
    public void stop() throws Exception {
        Stock.INDEX_STAGE.hide();
    }

    public static void main(String[] args) {
        launch(args);

    }
}
